package itheima.com.demo;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class SocketServerDemo {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(2222);
        Socket accept = ss.accept();
        ThreadPoolExecutor pool = new ThreadPoolExecutor(
                2,
                5,
                60,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(8),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy()
        );
        while (true) {
           ThreadPool tp = new ThreadPool(accept);
            pool.submit(tp);
        }

//        ss.close();

    }
}
